
function projectNoticeCtrl($scope, $http) {
  'ngInject';

  this.queryData = {};

  // 分页
  this.paginationData = {
    pageNum: 0,
    pageSize: 10,
    total: '5',
  }

  // 页码变化时调用方法
  $scope.pageChange = () => {

  	this.paginationData1 = {
  	  pageNum: this.paginationData.pageNum-1,
  	  pageSize: 10,
  	  total: '',
  	}

    $http.post(`${SERVER_CONTEXT}/api/user/app/notice/queryNoticeList`,
      	angular.extend(this.queryData, this.paginationData1)
      )
      .then((resp) => {
        this.projectNoticeList = resp.data.data;
        this.paginationData.total = resp.data.total;
    });
  };

  // 分页查询方法
  this.paginationQuery = () => {
    $http.post(`${SERVER_CONTEXT}/api/user/app/notice/queryNoticeList`,
      angular.extend(this.queryData, this.paginationData)
        )
      .then((resp) => {
        this.projectNoticeList = resp.data.data;
        this.paginationData.total = resp.data.total;
    });
  };

  // 获得发布单位
  this.getUnit = () => {
    $http.get(`${SERVER_CONTEXT}/api/user/app/notice/noticeUnit`)
      .then((resp) => {
        this.unit = resp.data;
    });
  }

  // 重置
  this.reset = () => {
    this.queryData = {};
  }

  // 查询
  this.query = (param) => {
  	// 发布开始时间大小判断
  	if(param.endTime.$viewValue && param.startTime.$viewValue){
  	  if (param.startTime.$viewValue < param.endTime.$viewValue) {
  	    this.paginationQuery();
	  	} else {
  	    layer.alert('发布开始时间应小于结束时间');
  	  }
  	} else {
  	  this.paginationQuery();
  	}
  }

  this.initPage = () => {
    // 获得发布单位
    this.getUnit();

  	// 获得列表数据
  	this.paginationQuery();
  }

  this.initPage();

}

export default projectNoticeCtrl;